package cloneExample;

import org.apache.commons.lang3.SerializationUtils;

/**
 * 深拷贝实现
 * 利用 apache.common.lang 实现
 */
public class CloneExample4 {
	public static void main(String[] args) {
		deepClone();
	}

	private static void deepClone() {
		Address address = new Address(110,"beijing");
		People p1 = new People(1, "Java", address);
		People p2 = SerializationUtils.clone(p1);
		p1.getAddress().setCity("guangzhou");
		// 两个内容不一致，说明了是两个对象。
		System.out.println("p1:" + p1.getAddress().getCity()); // guangzhou
		System.out.println("p2:" + p2.getAddress().getCity()); // beijing
	}
}
